import React, { useEffect } from 'react';

function promiseDemo() {
  return new Promise(function (resolve, reject) {
    // resolve(100);
    reject(new Error('promise rejected'));
  });
}

export default function PromiseDemo() {
  useEffect(() => {
    promiseDemo().then(
      function (result) {
        console.log('resolved', result);
      },
      function (error) {
        console.log('rejected', error);
      },
    );
  }, []);

  return (
    <div>
      <p>Promise 定义</p>
    </div>
  );
}
